package com.feidee.fd.sml.algorithm.feature

import com.feidee.fd.sml.algorithm.component.feature.{MaxAbsScaleEncoder, MaxAbsScaleEncoderParam}
import com.feidee.fd.sml.algorithm.util.{TestingDataGenerator, ToolClass}
import org.scalatest.FunSuite

/**
  * @author YongChen
  * @date 2018/12/25 10:18
  * @description
  * @email yong_chen@sui.com
  */
class MaxAbsScaleEncoderSuite extends FunSuite {

  val paramStr: String =
        """
     |{
     |	"input_pt": "a",
     |	"output_pt": "b",
     | "hive_table": "",
     | "flow_time": "",
     |	"inputCol": "features",
     |	"outputCol": "scaledFeatures",
     | "preserveCols": "",
     |	"modelPath": ""
     | }
    """.stripMargin

  val oneHot = new MaxAbsScaleEncoder()
  val param: MaxAbsScaleEncoderParam = oneHot.parseParam(new ToolClass().encrypt(paramStr))

  test("MaxAbsScalerEncoder parameter construction test") {
    assert(
          "a".equals(param.input_pt)
        & "b".equals(param.output_pt)
        & "".equals(param.hive_table)
        & "".equals(param.flow_time)
        & "features".equals(param.inputCol)
        & "scaledFeatures".equals(param.outputCol)
        & "".equals(param.preserveCols)
        & "".equals(param.modelPath)
    )
  }

  test("MaxAbsScalerEncoder training function test") {

    val testingData = TestingDataGenerator.makeChiSqSelectorData()
    new MaxAbsScaleEncoder().train(param, testingData).transform(testingData).show()

  }
}
